// 写入函数

const set = (name, value, { maxAge, domain, path, secure } = {}) => {
  let cookieText = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
  if (typeof maxAge === "number") {
    cookieText += `; max-age=${maxAge}`;
  }
  if (domain) {
    cookieText += `; domain=${domain}`;
  }
  if (path) {
    cookieText += `; path=${path}`;
  }
  if (secure) {
    cookieText += `; secure`;
  }
  document.cookie = cookieText;
};

export { set };
